package com.blog4j.server.modules.log.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.blog4j.common.model.Result;
import com.blog4j.requestRate.annotation.RequestRate;
import com.blog4j.server.modules.log.service.LogService;
import com.blog4j.server.modules.log.vo.req.LogListReqVo;
import com.blog4j.server.modules.log.vo.resp.LogRespVo;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author 98k灬
 * @version v1.0.0
 * @Description : 功能描述
 * @Create on : 2024/8/20 12:12
 **/
@RequestMapping("/log")
@RestController
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class LogController {
    private final LogService logService;

    /**
     * 日志信息分页查询
     *
     * @param reqVo 请求
     * @return 日志信息
     */
    @RequestRate
    @SaCheckLogin
    @PostMapping("/logList")
    public Result logList(@RequestBody @Valid LogListReqVo reqVo) {
        PageInfo<LogRespVo> pageInfo = logService.logList(reqVo);
        return Result.ok(pageInfo);
    }
}
